<template>
        <div id="NavMenu">
            <div class="menuHeader"></div>
            <ul>
                <li v-for="(item,key) in navMenu" :key="key" @click="showDetail(item,key)" class="menuLi"
                    :style="key==$store.state.lastSelected?{background:'white'}:{background:'rgba(234, 237, 241, 1)'}"
                >
                    {{item.permissionName}}
                </li>
            </ul>
        </div>
</template>

<script>
export default {
    props: {
        navMenu: {
            type: Array
        },
        navMenuIsVisiable: {
            type: Boolean,
            default: false
        },
        itemTitle: {
            type: String
        },
        startIndex: {
            type:Number,
            default: 0
        }
    },
    data(){
        return {
            lastSelected: 0
        }
    },
    methods: {
        showDetail(item,key){
            // 跳转的同时,记录跳转的name
            // this.lastSelected = key;
            localStorage.setItem("lastSelected",key);
            this.$store.commit('initLastSelected',localStorage.getItem('lastSelected'));
            this.$router.push({name: item.description})
        }
    },
    created(){
        //防止刷新之后,被选中的页面消失
        this.$store.commit('initLastSelected',localStorage.getItem('lastSelected'));
        // this.lastSelected = localStorage.getItem("lastSelected")?localStorage.getItem("lastSelected"):0;
    },
    updated(){

    }
}
</script>


<style lang="scss" scoped>

    #NavMenu {
        position: absolute;
        width: 146px;
        height: 100%;
        left: 146px;
        padding-top: 40px;
        box-shadow: 2px 0 2px rgba(0,0,0, 0.1); 
        background-color: rgba(234, 237, 241, 1);
        display: flex;
        flex-direction: column;
        &>*{
            font-family: '微软雅黑 Regular', '微软雅黑';
            font-weight: 400;
            font-style: normal;
            color: #999999;
        }
        .menuHeader {
            height: 46px;
            line-height: 46px;
            background: rgba(234, 237, 241, 1);
            border-color: rgb(136, 11, 11);;
            border-bottom: 1px solid rgba(228, 228, 228, 1);
            border-right: 1px solid rgba(228, 228, 228, 1);
        }
        ul {

            li {
                height: 50px;
                display: flex;
                justify-content: center;
                align-items: center;
                border-bottom: 1px solid lightgray;
                cursor: pointer;
                &:hover {
                    background: red;
                }
            }
        }
    }
</style>
